Skip to content

Language Translators

Alt text

Translation and execution of programs

  • Instructions in a program can only be executed when written in machine code and loaded into the main memory of a computer.
  • Programming instructions written in any programming language other than machine code must be translated before they can be used.
  • The systems software used to translate a source program written in any language other than machine code are translators.
  • There are three types of translator available, each translator performs a different role.
    • Assembler
    • Compiler
    • Interpreter

Assemblers

  • Programs written in assembly language are translated into machine code by an assembler program.

Compilers and interpreters

  • Programs written in a high-level language can be either translated into machine code by a compiler program, or directly executed line-by-line using an interpreter program.
AssemblerCompilerInterpreter
Source program written inassembly languagehigh-level languagehigh-level language
Machine dependentyesnono
Object program generatedyes, stored on disk or in main memoryyes, stored on disk or in main memoryno, instructions are executed under the control of the interpreter
Each line of the source program generatesone machine code instruction, one to one translationmany machine code instructions, instruction explosionmany machine code instructions, instruction explosion

CompilerInterpreter
The end user only needs the executable code, therefore, theend user benefits as there is no need to purchase a compiler to translate the program before it is used.The end user will need to purchase a compiler or aninterpreter to translate the source code before it is used.
The developer keeps hold of the source code, so it cannotbe altered or extended by the end user, therefore, the developer benefits as they can charge for upgrades and alterations.The developer relinquishes control of the source codemaking it more difficult to charge for upgrades and alterations. Since end users can view the source code, they could potentially use the developer's intellectual property.
Compiled programs take a shorter time to execute as translation has already been completed and the machine code generated may have been optimised by the compilerAn interpreted program can take longer to execute thanthe same program when compiled, since each line of the source code needs to be translated before it is execute every time the program is run.
Compiled programs have no syntax or semantic errorsInterpreted programs may still contain syntax or semanticerrors if any part of the program has not been fully testedthese errors will need to be debugged.
The source program can be translated on one type ofcomputer then executed on another type of computer.Interpreted programs cannot be interpreted on one typeof computer and run on another type of computer.
A compiler finds all errors in a program. One error detectedcan mean that the compiler finds other dependent errorsLater on in the program that will not be errors when thefirst error is corrected. Therefore, the number of errorsfound may be more than the actual number of errors.It is easier to develop and debug a program using aninterpreter as errors can be corrected on each line andthe program restarted from that place, enabling theprogrammer to easily learn from any errors.
Untested programs with errors may cause the computer to crash.Untested programs should not be able to cause thecomputer to crash.
The developer needs to write special routines in order toview partial results during development, making it moredifficult to assess the quality of particular sections of code.Partial results can be viewed during developmentenabling the developer to make informed decisions abouta section of code. for example whether to continue.modify, or scrap and start again.
End users do not have access to the source code andthe run-time libraries, meaning they are unable tomake modifications and are reliant on the developer forupdates and alterations.If an interpreted program is purchased, end users have all thesource code and the run-time libraries, enabling the programto be modified as required without further purchase.

Partial compiling and interpreting

  • In order to achieve shorter execution times, many high-level languages programs use a system that is partially compilation and partially interpretation.
  • The source code is checked and translated by a compiler into object code.
  • The compiled object code is a low-level machine independent code, called intermediate code, p-code or bytecode.

TIP

Source code:

py
print("Hello World")

Bytecode:

c
1 0 LOAD NAME
2 LOAD CONST
(print)
0 (Hello World')
4 CALL FUNCTION1 (1 positional,  keyword pair)
6 RETURNVALUE

Translator

The translator that can translate high level language into low level language:

[0/2]

Translator

The translator that can translate language as machine dependent:

[0/1]

Translator

The translator that generate object program(executable file):

[0/2]

Translator

The translator that translate language with one line to many lines machine code:

[0/2]

Translator

The translator that finds all errors in a program

[0/1]

Translator

The translator that is easier to develop and debug a program

[0/1]

Integrated development environment (IDE)

  • An integrated development environment (IDE) is used by programmers to aid the writing and development of programs.

  • IDEs usually have

    • a source code editor
    • a compiler, an interpreter, or both
    • a run-time environment with a debugger
    • an auto-documenter

features

  • coding
    • context-sensitive prompts
  • initial error detection
    • dynamic syntax checks
  • presentation
    • prettyprint
    • expandand collapse code blocks
  • debugging
    • single stepping
    • breakpoints
    • report window

Source code editor

  • A source code editor allows a program to be written and edited without the need to use a separate text editor.
  • Most source code editors colour code the words in the program and layout the program in a meaningful way (prettyprinting).

Alt text

Compiler, an interpreter, or both

  • Most IDEs usually provide a compiler and/or an interpreter to run the program. The interpreter is often used for developing the program and the compiler to produce the final version of the object code.

Alt text

Run-time environment with a debugger

  • A debugger is a program that runs the program under development and aids the process of debugging.
  • It allows the programmer to single step through the program a line at a time (single stepping) or to set a breakpoint to stop the execution of the program at a certain point in the source code.
  • A report window then shows the contents of the variables and expressions evaluated at that point in the program.
  • This allows the programmer to see if there are any logic errors in the program and check that the program works as intended.

Alt text

Auto-documenter

  • Most IDEs usually provide an auto-documenter to explain the function and purpose of programming code.

Alt text

IDE

An (IDE) is used by programmers to aid the writing and development of programs.

[0/1]

IDE

An IDE usually have:

[0/2]